import request from "@/utils/request";
import type { GetAttrListParams, AttrList, AttrItem } from "./model/attrModel";

enum Api {
  getAttrListUrl = "/admin/product/attrInfoList",
  addOrUpdataAttrUrl = "/admin/product/saveAttrInfo",
  deleteAttrListUrl = "/admin/product/deleteAttr",
}

export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: GetAttrListParams) => {
  return request.get<any, AttrList>(
    Api.getAttrListUrl + `/${category1Id}/${category2Id}/${category3Id}`
  );
};

export const addOrUpdataAttrApi = (data: AttrItem) => {
  return request.post<any, null>(Api.addOrUpdataAttrUrl, data);
};

export const deleteAttrListApi = (id: number) => {
  return request.delete<any, null>(Api.deleteAttrListUrl + `/${id}`);
};
